home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group98b.txt / 000174_icon-group-sender _Mon Aug 31 09:30:47 1998.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Return-Path: <icon-group-sender>
  2. Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
  3.     by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) with SMTP id JAA01134
  4.     for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Mon, 31 Aug 1998 09:30:45 -0700 (MST)
  5. Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
  6.     id AA20152; Mon, 31 Aug 1998 09:30:17 -0700
  7. Date: Mon, 31 Aug 1998 09:23:41 -0700
  8. From: kwalker@sfo.harbinger.com (Ken Walker)
  9. Message-Id: <199808311623.JAA20603@varda.premenos.com>
  10. To: icon-group@optima.CS.Arizona.EDU
  11. Subject: Re: A hood fan is guard to mind.
  12. Mime-Version: 1.0
  13. Content-Type: text/plain; charset=us-ascii
  14. Content-Transfer-Encoding: 7bit
  15. Content-Md5: 5qDOZPLcfV6WSo1n3qDQDQ==
  16. Content-Transfer-Encoding: 7bit
  17. Content-Transfer-Encoding: 7bit
  18. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  19. Content-Transfer-Encoding: 7bit
  20. Status: RO
  21. Content-Length: 1450
  22.  
  23. And here's a solution that does not involve passing "sentence" down
  24. the call chain.
  25.  
  26. procedure main()
  27.    local fillers, firstChar, remainingChars
  28.  
  29.    #
  30.    # The sentence is broken into three categories:
  31.    #   parts not participating in the substitution
  32.    #   the initial characters of the words involved in substitution
  33.    #   the tail of the words involved in substitution
  34.    #
  35.    fillers :=    ["A ",    " ",  " is ", " to ",    "."]
  36.    firstChar :=     ["g",    "m",   "h",     "f"]
  37.    remainingChars := ["ood",  "an",  "ard",    "ind"]
  38.  
  39.    every write(polyspoonerism(fillers, firstChar, remainingChars))
  40. end
  41.  
  42. procedure polyspoonerism(
  43.   fillers,        # words before each participating word
  44.   firstChar,      # first characters to use in substitutions
  45.   remainingChars) # words (w/out 1st char) that are participating
  46.  
  47.   local indx
  48.  
  49.   if *remainingChars = 0 then
  50.      return fillers[1] | ""
  51.  
  52.   #
  53.   # Use each of the remaining first characters
  54.   #
  55.   every indx := 1 to *firstChar  do {
  56.      #
  57.      # Construct the first part of the sentence then make a
  58.      # recursive call to construct the rest.
  59.      #
  60.      suspend fillers[1] || firstChar[indx] || remainingChars[1] ||
  61.         polyspoonerism(fillers[2:0], firstChar[1:indx] ||| firstChar[indx+1:0],
  62.         remainingChars[2:0])
  63.   }
  64. end
  65.  
  66. This is finally starting to look reasonably elegant and Iconish.
  67.  
  68. Ken Walker, kenneth.walker@sfo.harbinger.com
  69. Harbinger Coporation, Concord, Ca. 94520
  70.  
  71.